package com.example.mobile2030606155byl0401;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private TextView textView;
    private ImageView imageView;
    private Button btnXia;
    private int[] lines;
    private int linesID=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
        lines=new int[6];
        lines[0]=R.drawable.line01_01;
        lines[1]=R.drawable.line01_02;
        lines[2]=R.drawable.line01_03;
        lines[3]=R.drawable.line01_04;
        lines[4]=R.drawable.line01_05;
        lines[5]=R.drawable.line01_06;
        imageView.setImageResource(lines[linesID]);
        btnXia.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (linesID == 5) {
                    imageView.setImageResource(lines[0]);
                }else {
                    imageView.setImageResource(lines[linesID + 1]);
                    linesID += 1;
                }
            }
        });
    }

    private void initView() {
        textView = findViewById(R.id.textView);
        imageView = findViewById(R.id.imageView);
        btnXia = findViewById(R.id.btn_xia);
    }
}